package com.hanshunping.oop;

public class TestPerson {
    public static void main(String[] args) {
        Person p1 = new Person("赵方庆",20);
        Person p2 = new Person("赵方庆",20);
        System.out.println(p1.compareTo(p2));
    }
}
class Person{
    String name;
    int age;

    //有参的构造器
    Person(String name, int age){
        this.name = name;
        this.age = age;

    }
    //定义一个布尔类型的方法 用来判断是否和另外一个人相等
    public boolean compareTo(Person p){
        if(this.age == p.age && this.name.equals(p.name)) {
            return true;
        }else{
            return false;
        }
    }
}
